<?php

namespace app\admin\validate\professionalqa;

use ShidianUtil\Thinkphp\Validate\BaseValidate;

/**
 * Class Category
 * @package app\professionalqa\validate
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037623
 */
class Category extends BaseValidate
{

    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'isId',
        'userId' => 'integer|egt:0|max:11',
        'name' => 'scalar|max:60',
        'ord' => 'integer|egt:0|max:5',
        'remarks' => 'scalar',
        'smallPic' => 'scalar|max:200',
        'updated' => 'integer|egt:0|max:11',
        'created' => 'integer|egt:0|max:11',
        'page' => 'integer|egt:0|max:11',
        'page_size' => 'integer|egt:0|max:11',
    ];

    protected $field = [
        'id' => 'id',
        'userId' => 'userId',
        'name' => '名称',
        'ord' => '排序',
        'remarks' => '备注',
        'smallPic' => '图标',
        'updated' => 'updated',
        'created' => 'created',
        'page' => '分页页数',
        'page_size' => '分页大小',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => '缺少:attribute',
        'id.isId' => '请设置正确的:attribute',
        'userId.require' => '请输入:attribute',
        'userId.integer' => ':attribute应该是整数',
        'userId.egt' => ':attribute应该大于等于:rule',
        'userId.max' => ':attribute长度不能超过:rule位',
        'name.require' => '请输入:attribute',
        'name.scalar' => ':attribute应该是字符串',
        'name.max' => ':attribute长度不能超过:rule位',
        'ord.require' => '请输入:attribute',
        'ord.integer' => ':attribute应该是整数',
        'ord.egt' => ':attribute应该大于等于:rule',
        'ord.max' => ':attribute长度不能超过:rule位',
        'remarks.require' => '请输入:attribute',
        'remarks.scalar' => ':attribute应该是字符串',
        'smallPic.require' => '请上传:attribute',
        'smallPic.scalar' => ':attribute应该是字符串',
        'smallPic.max' => ':attribute长度不能超过:rule位',
        'updated.require' => '请输入:attribute',
        'updated.integer' => ':attribute应该是整数',
        'updated.egt' => ':attribute应该大于等于:rule',
        'updated.max' => ':attribute长度不能超过:rule位',
        'created.require' => '请输入:attribute',
        'created.integer' => ':attribute应该是整数',
        'created.egt' => ':attribute应该大于等于:rule',
        'created.max' => ':attribute长度不能超过:rule位',
        'page.require' => '请输入:attribute',
        'page.integer' => ':attribute应该是整数',
        'page.egt' => ':attribute应该大于等于:rule',
        'page.max' => ':attribute长度不能超过:rule位',
        'page_size.require' => '请输入:attribute',
        'page_size.integer' => ':attribute应该是整数',
        'page_size.egt' => ':attribute应该大于等于:rule',
        'page_size.max' => ':attribute长度不能超过:rule位',
    ];

    protected $scene = [
        'delete' => ['id' => 'require'],
        'index' => ['page', 'page_size'],
        'read' => ['id' => 'require'],
        'save' => ['name' => 'require', 'ord', 'remarks', 'smallPic' => 'require', 'updated', 'created'],
    ];

}
